package com.ecoolex.hotel.saas.job.scheduler;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.ecoolex.framework.scheduler.Job;
import com.ecoolex.framework.scheduler.JobComponent;
import com.ecoolex.hotel.saas.core.manager.StoreAdManager;

@JobComponent
public class StoreAdCheckExpiredJob {

	private Logger log = LoggerFactory.getLogger(StoreAdCheckExpiredJob.class);

	@Autowired
	private StoreAdManager storeAdManager;

	@Job(name = "hotel.saas.StoreAdCheckExpiredJob.checkExpired", describe = "检查过期广告")
	public void process() {
		log.debug("调度={}", this.getClass());
		try {
			int row = storeAdManager.checkExpiredAndUpdateStatus(StoreAdCheckExpiredJob.class.getSimpleName());
			if (row > 0) {
				log.info("检查到广告过期{}条", row);
			}
		} catch (Exception e) {
			log.error("调度异常", e);
		} finally {
			log.debug("调度结束={}", this.getClass());
		}

	}
}
